local skel = fk.CreateSkill {
  name = "lb__ruchu",
}

Fk:loadTranslationTable {
  ["lb__ruchu"] = "如初",
  [":lb__ruchu"] = "当你死亡时，你可选择一名拥有<a href=':lb__zhuhuo'><font color='red'>〖逐火〗</font></a>的其他角色，交给其所有手牌并成为其副将，其获得本轮所有因<a href=':lb__shiyue'><font color='red'>〖诗约〗</font></a>获得过的不重复技能，然后失去“昔涟”的所有技能。",

  ["#lb__ruchu"] = "如初：你可以选择一名拥有〖逐火〗的其他角色，交给其所有手牌并成为其副将，其获得本轮所有因〖诗约〗获得过的不重复技能，然后失去“昔涟”的所有技能",

  ["$lb__ruchu1"] = "收下吧，我们的答案！",
  ["$lb__ruchu2"] = "要用爱铭记我，在那美丽的明天。",
  ["$lb__ruchu3"] = "下一页是空白呢，那我们一起写下吧。",
}
skel:addEffect(fk.Death, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name, false, true) and target == player
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = room:askToChoosePlayers(player, {
      targets = room:getOtherPlayers(player),
      min_num = 1,
      max_num = 1,
      skill_name = skel.name,
      cancelable = true,
      prompt = "#lb__ruchu",
    })
    if #tos > 0 then
      event:setCostData(self, { tos = tos })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    if not player:isKongcheng() then
      room:moveCardTo(player:getCardIds("h"), Card.PlayerHand, to, fk.ReasonGive, skel.name, nil, false, player)
    end
    if to.deputyGeneral ~= "lb__xilian" and to:isAlive() then
      room:changeHero(to, "lb__xilian", false, true, true, false)
    end
    local player_skills = player:getTableMark("@[lb__shiyue]lb__shiyue")
    if player_skills[tostring(to.id)] then
      player_skills[tostring(to.id)] = nil   --不再移除诗约技能
      room:setPlayerMark(player, "@[lb__shiyue]lb__shiyue", player_skills)
    end
    local skills = player:getTableMark("@[skills]lb__shiyue-round")
    if #skills > 0 then
      for _, name in ipairs(skills) do
        if not to:hasSkill(name, true) then
          room:handleAddLoseSkills(to, name)
        end
      end
    end
    for _, name in ipairs(Fk.generals["lb__xilian"]:getSkillNameList()) do
      if to:hasSkill(name, true) then
        room:handleAddLoseSkills(to, "-" .. name)
      end
    end
  end,
})

return skel
